<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="common :: common('修改资料')">
</head>
<form id="personalForm" action="/sys/user/editUser">
	<div class="box-body">
		<input type="hidden" id="editId" name="id">
		<div class="form-group">
			<label>账号 </label><input type="text" id="editUsername"
				class="form-control" placeholder="账号" readonly>
		</div>
		<div class="form-group">
			<label>名字 </label><input type="text" id="editName" name="name"
				class="form-control " placeholder="名字">
		</div>
		<div class="form-group">
			<label>邮箱 </label><input type="text" id="editEmail" name="email"
				class="form-control" placeholder="邮箱">
		</div>
		<div class="form-group">
			<label>电话 </label><input type="text" id="editPhone" name="phone"
				class="form-control" placeholder="电话">
		</div>
		<div class="form-group">
			<label>生日 </label> <input type="text" id="editBirthday"
				name="birthday" class="form-control" placeholder="生日">
		</div>
		<div class="form-group">
			<label>性别 </label><input type="radio" name="sex" value="1" checked>
			男 <input type="radio" name="sex" value="2"> 女

		</div>
	</div>
	<!-- /.box-body -->
	<div class="box-footer">
		<div class="pull-right">
			<button type="submit" class="btn btn-success">
				<i class="fa fa-floppy-o" aria-hidden="true"></i> 保存
			</button>
		</div>
	</div>
	<!-- /.box-footer -->
</form>
<script type="text/javascript" th:inline="javascript">
	$(function() {
		$('input').iCheck({
			checkboxClass : 'icheckbox_square-blue',
			radioClass : 'iradio_square-blue',
			increaseArea : '20%' /* optional */
		});
		var sysUser = [[${sysUser}]];
		$('#editId').val(sysUser.id);
		$('#editUsername').val(sysUser.username);
		$('#editName').val(sysUser.name);
		$('#editEmail').val(sysUser.email);
		$('#editPhone').val(sysUser.phone);
		$('#editBirthday').val(sysUser.birthday);
		var sex = sysUser.sex;
		$('#personalForm input:radio[name=sex][value=' + sex + ']').iCheck('check');
		$('#editBirthday').datepicker({
			language : "zh-CN",
			format : "yyyy-mm-dd"
		});

		$('#personalForm').bootstrapValidator({
			message : '这个值是无效的',
			feedbackIcons : {
				valid : 'fa fa-check',
				invalid : 'fa fa-remove',
				validating : 'fa fa-refresh'
			},
			fields : {
				name : {
					validators : {
						notEmpty : {}
					}
				}
			}
		}).on('success.form.bv', function(e) {
			// Prevent form submission
			e.preventDefault();

			// Get the form instance
			var $form = $(e.target);

			// Get the BootstrapValidator instance
			var bv = $form.data('bootstrapValidator');

			layer.confirm('确定保存？', {
				icon : 3,
				title : '提示'
			}, function(index) {
				// Use Ajax to submit form data
				$.post($form.attr('action'), $form.serialize(), function(result) {
					if (result.success) {
						layer.msg(result.msg, {
							icon : 6
						});
					} else {
						layer.msg(result.errorMsg, {
							icon : 5
						});
					}
				}, 'json');
			});
		});
	});
</script>
</html>